﻿using EFEntity;
using Iservices;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Services
{
    public class human_fileServices : Ihuman_fileServices
    {
        private readonly MyDbContext myDBContext;

        public human_fileServices(MyDbContext myDBContext)
        {
            this.myDBContext = myDBContext;
        }
        public async Task<List<human_file>> FenYe(FenYe fy)
        {
            var data = myDBContext.human_file.OrderBy(e => e.huf_id).ToList();
            fy.Rows = data.Count();
            fy.Pages = (fy.Rows - 1) / fy.PageSize + 1;
            List<Ehuman_file> list = new List<Ehuman_file>();
            await Task.Run(() =>
            {
                list = data.Skip((fy.CurrentPage - 1) * fy.PageSize)
                    .Take(fy.PageSize)
                    .ToList();
            });
            //把EO-DTO
            List<human_file> list2 = new List<human_file>();
            foreach (Ehuman_file item in list)
            {
                human_file t = new human_file()
                {

                    huf_id = item.huf_id,
                    human_id = item.human_id,
                    first_kind_id = item.first_kind_id,
                    first_kind_name = item.first_kind_name,
                    second_kind_id = item.second_kind_id,
                    second_kind_name = item.second_kind_name,
                    third_kind_id = item.third_kind_id,
                    third_kind_name = item.third_kind_name,
                    human_name = item.human_name,
                    human_pro_designation = item.human_pro_designation,
                    human_address = item.human_address,
                    human_postcode = item.human_postcode,
                    human_major_kind_id = item.human_major_kind_id,
                    human_major_kind_name = item.human_major_kind_name,
                    human_major_id = item.human_major_id,
                    hunma_major_name = item.hunma_major_name,
                    human_telephone = item.human_telephone,
                    human_bank = item.human_bank,
                    human_mobilephone = item.human_mobilephone,
                    human_account = item.human_account,
                    human_qq = item.human_qq,
                    human_email = item.human_email,
                    human_hobby = item.human_hobby,
                    human_speciality = item.human_speciality,
                    human_sex = item.human_sex,
                    human_religion = item.human_religion,
                    human_party = item.human_party,
                    human_nationality = item.human_nationality,
                    human_race = item.human_race,
                    human_birthday = item.human_birthday,
                    human_age = item.human_age,
                    human_educated_degree = item.human_educated_degree,
                    human_educated_years = item.human_educated_years,
                    human_educated_major = item.human_educated_major,
                    human_society_security_id = item.human_society_security_id,
                    human_id_card = item.human_id_card,
                    remark = item.remark,
                    salary_standard_id = item.salary_standard_id,
                    salary_standard_name = item.salary_standard_name,
                    salary_sum = item.salary_sum,
                    demand_salaray_sum = item.demand_salaray_sum,
                    paid_salary_sum = item.paid_salary_sum,
                    major_change_amount = item.major_change_amount,
                    bonus_amount = item.bonus_amount,
                    training_amount = item.training_amount,
                    file_chang_amount = item.file_chang_amount,
                    human_histroy_records = item.human_histroy_records,
                    human_family_membership = item.human_family_membership,
                    attachment_name = item.attachment_name,
                    check_status = item.check_status,
                    register = item.register,
                    regist_time = item.regist_time,
                    checker = item.checker,
                    check_time = item.check_time,
                    changer = item.changer,
                    change_time = item.change_time,
                    lastly_change_time = item.lastly_change_time,
                    delete_time = item.delete_time,
                    recovery_time = item.recovery_time,
                    human_file_status = item.human_file_status,

                };
                list2.Add(t);
            }
            return list2;
        }
        public async Task<List<human_file>> Select()
        {
            List<Ehuman_file> list = new List<Ehuman_file>();
            await Task.Run(() =>
            {
                list = myDBContext.human_file.ToList();

            });
            //Automap
            List<human_file> list2 = new List<human_file>();
            foreach (Ehuman_file item in list)
            {
                human_file t = new human_file()
                {
                    huf_id = item.huf_id,
                    human_id = item.human_id,
                    first_kind_id = item.first_kind_id,
                    first_kind_name = item.first_kind_name,
                    second_kind_id = item.second_kind_id,
                    second_kind_name = item.second_kind_name,
                    third_kind_id = item.third_kind_id,
                    third_kind_name = item.third_kind_name,
                    human_name = item.human_name,
                    human_pro_designation = item.human_pro_designation,
                    human_address = item.human_address,
                    human_postcode = item.human_postcode,
                    human_major_kind_id = item.human_major_kind_id,
                    human_major_kind_name = item.human_major_kind_name,
                    human_major_id = item.human_major_id,
                    hunma_major_name = item.hunma_major_name,
                    human_telephone = item.human_telephone,
                    human_bank = item.human_bank,
                    human_mobilephone = item.human_mobilephone,
                    human_account = item.human_account,
                    human_qq = item.human_qq,
                    human_email = item.human_email,
                    human_hobby = item.human_hobby,
                    human_speciality = item.human_speciality,
                    human_sex = item.human_sex,
                    human_religion = item.human_religion,
                    human_party = item.human_party,
                    human_nationality = item.human_nationality,
                    human_race = item.human_race,
                    human_birthday = item.human_birthday,
                    human_age = item.human_age,
                    human_educated_degree = item.human_educated_degree,
                    human_educated_years = item.human_educated_years,
                    human_educated_major = item.human_educated_major,
                    human_society_security_id = item.human_society_security_id,
                    human_id_card = item.human_id_card,
                    remark = item.remark,
                    salary_standard_id = item.salary_standard_id,
                    salary_standard_name = item.salary_standard_name,
                    salary_sum = item.salary_sum,
                    demand_salaray_sum = item.demand_salaray_sum,
                    paid_salary_sum = item.paid_salary_sum,
                    major_change_amount = item.major_change_amount,
                    bonus_amount = item.bonus_amount,
                    training_amount = item.training_amount,
                    file_chang_amount = item.file_chang_amount,
                    human_histroy_records = item.human_histroy_records,
                    human_family_membership = item.human_family_membership,
                    attachment_name = item.attachment_name,
                    check_status = item.check_status,
                    register = item.register,
                    regist_time = item.regist_time,
                    checker = item.checker,
                    check_time = item.check_time,
                    changer = item.changer,
                    change_time = item.change_time,
                    lastly_change_time = item.lastly_change_time,
                    delete_time = item.delete_time,
                    recovery_time = item.recovery_time,
                    human_file_status = item.human_file_status,


                };
                list2.Add(t);
            }
            return list2;
        }
    }
}
